import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import mars3dCesium from "vite-plugin-mars3d";

import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'


// https://vitejs.dev/config/
export default defineConfig({
  esbuild: {
    loader: 'ts',
  },
  optimizeDeps: {
    include: ['src/utils/layer.ts'],
  },
  plugins: [
    vue(),
    Components({   //添加了element按需导入
      resolvers: [ElementPlusResolver()],
    }),
    mars3dCesium(), //关键代码，引入插件
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  // devServer: {
  //   proxy: {  //proxy代理的意思
  //     // 我们在发送请求时,是往http://localhost:8081/calendar/发送请求
  //     //这种配置项写法的含义是,当检测到/calendar配置项时,会往http://v.juhe.cn的服务器地址转发
  //     '/geoserver': {
  //       target: 'http://localhost:8080/',
  //     },
  //   },
  // },
})
